package IO;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

/**
 *
 * 随机存取流——能同时充当输入、输出流、输入输出流
 * @author 15594
 */
public class RandomStream {
    public static void main(String[] args) throws IOException {
        /**mode参数可取，r、rw、rwd、rws  r为读取流、rw为可读可写流*/

        RandomAccessFile randomAccessFile = new RandomAccessFile("random.txt","rw");
        randomAccessFile.writeUTF("你好,RandomStream");

        randomAccessFile.seek(0);
        String s = randomAccessFile.readUTF();
        System.out.println(s);
        randomAccessFile.close();

    }
}


